home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
1122
/
1122.xpi
/
chrome
/
tabmixplus.jar
/
content
/
tabmixplus
/
minit
/
tablib.js
< prev
Wrap
Text File
|
2009-10-12
|
73KB
|
1,951 lines
// code modified by Hemiola SUN, 2005-04-14 and fixed by onemen
if(!window.tablib || tablib.version != "tabmixplus")
var tablib = {
version : "tabmixplus",
_inited: false,
init : function() {
if (this._inited)
return;
this._inited = true;
if(gBrowser.mTabs.length > 0)
gBrowser.mCurrentTab._selected = true;
// NRA-ILA toolbar extension raplce the original addTab function
var _addTab = "addTab";
if ("origAddTab7c3de167ed6f494aa652f11a71ecb40c" in gBrowser)
_addTab = "origAddTab7c3de167ed6f494aa652f11a71ecb40c";
eval("gBrowser." + _addTab + " =" + gBrowser[_addTab].toString().replace(
'var blank = aURI == "about:blank";',
'var blank = !aURI || aURI == "about:blank";'
).replace(
't.setAttribute("label", aURI);',
't.setAttribute("label", gWidthFitTitle ? this.mStringBundle.getString("tabs.loading") : aURI);'
).replace(
't.width = 0;',
't.style.maxWidth = t.maxWidth + "px";'
).replace(
't.setAttribute("flex", "100");',
'if (!gWidthFitTitle) { \
t.width = 0; \
$& \
} else t.setAttribute("newtab", "true");'
).replace(
't.dispatchEvent(evt);',
'$& this.TMP_openTabNext(t, arguments.callee.caller.name);'
).replace( /* Bug 465673 Change 'Default' Tab Opening Behavior/Position for Firefox - landed on 3.7a1pre 2009-09-05
we don't use it for now */
'this.mPrefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent")',
'false'
));
// ContextMenu Extensions raplce the original removeTab function
var _removeTab = "removeTab";
if ("__ctxextensions__removeTab" in gBrowser)
_removeTab = "__ctxextensions__removeTab";
if (gIsFirefox35) {
// for Firefox 3.5+ //
eval("gBrowser." + _removeTab + " =" + gBrowser[_removeTab].toString().replace(
'{',
'{ \
if (this.mTabContainer.childNodes.length == 1 && this.mPrefs.getBoolPref("extensions.tabmix.keepLastTab")) return; \
if (aTab.hasAttribute("protected")) return;\
aTab.clearTimeouts();'
));
eval("gBrowser._endRemoveTab ="+gBrowser._endRemoveTab.toString().replace(
'aTab.collapsed = true;',
'if (this.mTabs.length == this._removingTabs.length) aTab.collapsed = true; \
else aTab.hidden = true;'
).replace(
'this.addTab("about:blank");',
'TMP_BrowserOpenTab(null, true);'
).replace(
'this._blurTab(aTab);',
'TMP_onRemoveTab(aTab, browser); \
this.mTabContainer.nextTab = 1; \
$&'
));
eval("gBrowser._blurTab ="+gBrowser._blurTab.toString().replace(
'if (aTab.owner &&',
'if (false &&'
).replace(
'var tab = aTab;',
'var tab, newIndex = this.selectIndexAfterRemove(aTab);\
if (newIndex > -1) {\
tab = this.mTabContainer.childNodes[newIndex];\
if (tab && this._removingTabs.indexOf(tab) == -1) {\
this.selectedTab = tab;\
return;\
}\
}\
tab = aTab;'
));
}
else {
// for Firefox 3.0 //
eval("gBrowser." + _removeTab + " =" + gBrowser[_removeTab].toString().replace(
'var l = this.mTabContainer.childNodes.length;',
'if (aTab.hasAttribute("protected")) return; \
aTab.clearTimeouts(); \
$&'
).replace(
'var oldTab = aTab;',
'$& TMP_onRemoveTab(oldTab, oldBrowser); \
var tabmixIndex = this.selectIndexAfterRemove(oldTab); \
if (tabmixIndex > oldTab._tPos) tabmixIndex--;'
).replace(
'this.selectedTab = this.mTabContainer.childNodes[newIndex];',
'this.mTabContainer.nextTab = 1; \
if (tabmixIndex > -1) newIndex = tabmixIndex; \
$&'
).replace(
'this.addTab("about:blank");',
'if (this.mPrefs.getBoolPref("extensions.tabmix.keepLastTab")) \ return; \
aTab.collapsed = true; \
TMP_BrowserOpenTab(null, true);'
));
}
eval("gBrowser.mTabContainer._selectNewTab" + " ="+gBrowser.mTabContainer._selectNewTab.toString().replace(
'{',
'{if(!this.mPrefs.getBoolPref("extensions.tabmix.mouseDownSelect") && arguments.callee.caller.name == "setTab") return; '
));
eval("BrowserCloseTabOrWindow ="+BrowserCloseTabOrWindow.toString().replace(
/closeWindow\(true\);/g,
'TMP_closeLastTab();'
).replace(
/gBrowser.removeCurrentTab\(\);/g,
'TMP_closeLastTab();'
).replace(
/gBrowser.removeCurrentTab\(true\);/g,
'TMP_closeLastTab();'
).replace(
'BrowserCloseWindow();',
'TMP_closeLastTab();'
));
//don't open link from external application in new window when in single window mode
//don't open link from external application in current tab if the tab is locked
var _openURI = nsBrowserAccess.prototype.openURI.toString();
if (gIsFirefox35) {
// after Bug 324164 - Unify Single Window Mode Preferences
_openURI = _openURI.replace(
'aWhere = gPrefService.getIntPref("browser.link.open_newwindow");',
'if (isExternal) aWhere = TMP_getIntPref("", "browser.link.open_external",3); \
else $&'
).replace(
'let loadBlankFirst =',
'$& currentIsBlank ||'
);
}
_openURI = _openURI.replace(
'switch (aWhere) {',
'if (gSingleWindowMode && aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW) {\
aWhere = Ci.nsIBrowserDOMWindow.OPEN_NEWTAB;}\
if (aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW && aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWTAB){\
var isLockTab = TMP_whereToOpen(null).lock; if(isLockTab) aWhere = Ci.nsIBrowserDOMWindow.OPEN_NEWTAB;}\
$&'
).replace(
'("browser.tabs.loadDivertedInBackground");',
'$& \
let currentIsBlank = win.gBrowser.isBlankNotBusyTab(win.gBrowser.mCurrentTab);'
).replace(
'win.gBrowser.loadOneTab',
'currentIsBlank ? win.gBrowser.mCurrentTab : $&'
).replace(
'if (needToFocusWin',
'if (currentIsBlank && !loadInBackground)\
win.content.focus();\
$&'
);
eval("nsBrowserAccess.prototype.openURI ="+_openURI);
//inverse focus of middle/ctrl/meta clicked links
eval("openNewTabWith ="+openNewTabWith.toString().replace(
'if (aEvent && aEvent.shiftKey)',
'if (aEvent && (aEvent.button == 1 || aEvent.button == 0 && ( aEvent.ctrlKey || aEvent.metaKey )) && (prefSvc.getBoolPref("extensions.tabmix.inversefocusLinks") || !prefSvc.getBoolPref("extensions.tabmix.inversefocusLinks") && aEvent.shiftKey))'
));
eval("FillHistoryMenu ="+FillHistoryMenu.toString().replace(
/entry.title/g,
'menuItemTitle(entry)'
));
// Chromin Frame put gBrowser.updateTitlebar in gChrominFrame._origupdateTitlebar
var chrominFrame = "gChrominFrame" in window && "_origupdateTitlebar" in gChrominFrame;
var fnName = chrominFrame ? "_origupdateTitlebar" : "updateTitlebar";
var objName = chrominFrame ? "gChrominFrame" : "gBrowser";
eval(objName + "." + fnName + " ="+window[objName][fnName].toString().replace(
'if (!docTitle)',
'var url = this.contentDocument.baseURI || this.currentURI.spec; \
if (this.mCurrentTab.getAttribute("label-uri") == url || this.mCurrentTab.getAttribute("label-uri") == "*") docTitle = this.mCurrentTab.getAttribute("fixed-label"); \
else docTitle = getTitleFromBookmark(url, docTitle, this.mCurrentTab.getAttribute("tabmix_bookmarkId")); \
$&'
));
eval("gBrowser.setTabTitle ="+gBrowser.setTabTitle.toString().replace(
'if (!title) {',
'if (gWidthFitTitle) { var cIndex = this.mTabContainer.selectedIndex; \
var currentTabVisible = this.mTabContainer.isTabVisible(cIndex); } \
var url = browser.contentDocument.baseURI || browser.currentURI.spec; \
if (aTab.getAttribute("label-uri") == url || aTab.getAttribute("label-uri") == "*") title = aTab.getAttribute("fixed-label"); \
else title = getTitleFromBookmark(url, title, aTab.getAttribute("tabmix_bookmarkId")); \
$&'
).replace(
'aTab.setAttribute("crop", crop);',
<![CDATA[$&
if (aTab.hasAttribute("mergeselected"))
aTab.label = "(*) " + aTab.label;
if (gWidthFitTitle) {
let width;
if (aTab.hasAttribute("width")) {
width = aTab.boxObject.width;
aTab.removeAttribute("width");
}
let newWidth = aTab.boxObject.width;
if (newWidth && newWidth != width) {
tabBarScrollStatus();
checkBeforeAndAfter();
if (currentTabVisible)
this.mTabContainer.ensureTabIsVisible(cIndex);
}
}
]]>
));
eval("window.BrowserGoHome ="+window.BrowserGoHome.toString().replace(
'var where = whereToOpenLink(aEvent);',
'$& \ if (where == "current" && TMP_whereToOpen(false).inNew) where = "tab";'
).replace(
'var where = whereToOpenLink(aEvent, false, true);',
'$& \ if (where == "current" && TMP_whereToOpen(false).inNew) where = "tab";'
));
// before Firfox 3.6 newWindowButtonObserver.onDragOver return true and from version 3.6 return witout value
var newString = gIsFirefox36 ? "return;" : "return true;";
eval("newWindowButtonObserver.onDragOver ="+newWindowButtonObserver.onDragOver.toString().replace(
'{',
'{ \
if (gSingleWindowMode) { \
if (!aEvent.target.hasAttribute("disabled")) \
aEvent.target.setAttribute("disabled", true);\
NEWSTRING \
}'
).replace('NEWSTRING', newString));
eval("newWindowButtonObserver.onDrop ="+newWindowButtonObserver.onDrop.toString().replace(
'{',
'{ if (gSingleWindowMode) return;'
));
// fix webSearch to open new tab if tab is lock
eval("BrowserSearch.webSearch ="+BrowserSearch.webSearch.toString().replace(
'loadURI(searchForm, null, null, false);',
'gBrowser.TMP_openURI(searchForm);'
));
gBrowser.TMP_openURI = function (uri) {
var openNewTab = TMP_whereToOpen(true).lock;
if (openNewTab)
this.loadOneTab(uri, null, null, null, false, false);
else
loadURI(uri, null, null, false);
}
// Firefox 3.6 gIsFirefox36
// warnAboutClosingWindow in window from Bug 354894 29/07/2009
if ("warnAboutClosingWindow" in window) {
eval("warnAboutClosingWindow ="+warnAboutClosingWindow.toString().replace(
/return gBrowser.warnAboutClosingTabs\(true\);/g,
'return TMP_closeWindow(true);'
).replace(
'os.notifyObservers(null, "browser-lastwindow-close-granted", null);',
'if (!(/^Mac/.test(navigator.platform)) && !TMP_closeWindow(true)) return false;\
$&'
));
eval("closeWindow ="+closeWindow.toString().replace(
'else if (windowCount != 1',
'else if (windowCount == 1 && !inPrivateBrowsing && !TMP_closeWindow()) return false;\
$&'
));
}
else {
/* For Firefox 3.0 */
eval("WindowIsClosing ="+WindowIsClosing.toString().replace(
'return closeWindow(false,',
'return TMP_closeWindow(); $&'
).replace( // Firefox 3.5
'var reallyClose = closeWindow(false, function () {return gBrowser.warnAboutClosingTabs(true);});',
'var reallyClose = TMP_closeWindow();'
));
}
eval("goQuitApplication ="+goQuitApplication.toString().replace(
'var appStartup',
'if(!SessionManager.canQuitApplication()) \
return false; \
$&'
));
eval("HistoryMenu.toggleRecentlyClosedTabs ="+HistoryMenu.toggleRecentlyClosedTabs.toString().replace(
'if (ss.getClosedTabCount(window) == 0)',
'if (TMP_ClosedTabs.count == 0)'
));
// disable undo closed window when single window mode is on
if (gIsFirefox35) {
eval("HistoryMenu.toggleRecentlyClosedWindows ="+HistoryMenu.toggleRecentlyClosedWindows.toString().replace(
'if (this._ss.getClosedWindowCount() == 0)',
'if (this._ss.getClosedWindowCount() == 0 || gSingleWindowMode)'
));
eval("HistoryMenu.populateUndoWindowSubmenu ="+HistoryMenu.populateUndoWindowSubmenu.toString().replace(
'var undoPopup = document.getElementById("historyUndoWindowPopup");',
'var id = arguments.length == 1 ? arguments[0] : "historyUndoWindowPopup"; \
var undoPopup = document.getElementById(id);'
).replace(
'undoPopup.appendChild(m);',
'm.setAttribute("value", i); \
m.addEventListener("click", SessionManager.checkForMiddleClick, false); \
$&'
).replace(
'm.id = "menu_restoreAllWindows";',
'$& \
m.setAttribute("value", -2);'
).replace(
'var m = undoPopup.appendChild(document.createElement("menuitem"));',
'$& \
m.id = "menu_clearClosedWindowsList"; \
var strings = document.getElementById("tmp-string-bundle"); \
m.setAttribute("label", strings.getString("undoClosedWindows.clear.label")); \
m.setAttribute("accesskey", strings.getString("undoClosedWindows.clear.accesskey")); \
m.setAttribute("value", -1); \
m.setAttribute("oncommand", "SessionManager.forgetClosedWindow(-1);"); \
m = undoPopup.appendChild(document.createElement("menuitem"));'
));
var popup = document.getElementById("historyUndoWindowPopup");
if (popup)
popup.setAttribute("contextmenu", "tm_undocloseWindowContextMenu");
}
// check multi-row status when we get out of fullscreen
eval("FullScreen.mouseoverToggle="+FullScreen.mouseoverToggle.toString().replace(
'gBrowser.mStrip.setAttribute("moz-collapsed", !aShow);',
'if (aShow && gHideTabBar != 2) gTMPprefObserver.setTabBarVisibility(true); \
else $&'
));
if (gisToolbarMode) {
// after bug 347930 - change Tab strip to be a toolbar
eval("gBrowser.setStripVisibilityTo ="+gBrowser.setStripVisibilityTo.toString().replace(
'if (this._toolbar && this.mPrefs.getBoolPref("browser.tabs.autoHide"))',
'if (this._toolbar && (!aShow || gHideTabBar != 2))'
));
// add tabs-toolbar to the toolbar popup list when the tabbar is on the bottom
eval("onViewToolbarsPopupShowing="+onViewToolbarsPopupShowing.toString().replace(
/(\})(\)?)$/,
'TMP_onViewToolbarsPopupShowing(popup, firstMenuItem); \
$1$2'
));
// make sure that tabs-toolbar is on the top before we enter customize toolbar mode
var _command = document.getElementById("cmd_CustomizeToolbars");
if (_command)
_command.setAttribute("oncommand", "TMP_BrowserCustomizeToolbar();" + _command.getAttribute("oncommand"));
}
else {
eval("gBrowser.setStripVisibilityTo ="+gBrowser.setStripVisibilityTo.toString().replace(
'this.mStrip.collapsed = !aShow;',
'if (!aShow || gHideTabBar != 2) $&'
));
}
/*
*
* Fix compatibility with other extensions
*
*/
// linkification extension
if ("objLinkify" in window && "ClickLink" in objLinkify)
eval("objLinkify.ClickLink ="+objLinkify.ClickLink.toString().replace(
'if (bOpenWindow)',
'if (bOpenWindow && !gSingleWindowMode)'
).replace(
'if (bOpenTab)',
'if (bOpenTab || TMP_whereToOpen(null).lock)'
));
// trigger tabmix function when user change tab width with faviconize extension
if ("faviconize" in window && "toggle" in faviconize)
eval("faviconize.toggle = " + faviconize.toggle.toString().replace(
/}$/,
'tabBarScrollStatus(); checkBeforeAndAfter(); $&'
));
// make ChromaTabs extension compatible with Tabmix Plus
if ("CHROMATABS" in window)
eval("CHROMATABS.colorizeTab ="+CHROMATABS.colorizeTab.toString().replace(
'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-image-left");',
'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-image-left tab-startcap tab-left tab-left-border");'
).replace(
'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-image-middle");',
'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-middle box-inherit tab-image-middle tab-body");'
).replace(
'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-close-button");',
'node = doc.getAnonymousElementByAttribute(tab, "anonid", "tmp-close-button");'
).replace(
'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-image-right");',
'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-image-right tab-endcap tab-right tab-right-border");'
));
// fix bug in superDargandGo
try {
if ("superDrag" in window)
eval("contentAreaDNDObserver.onDrop ="+contentAreaDNDObserver.onDrop.toString().replace(
'document.firstChild.getAttribute("windowtype")',
'window.document.documentElement.getAttribute("windowtype")'
).replace(
'preventBubble()',
'stopPropagation()'
));
} catch (ex) {}
// make URL Suffix extension compatible with tabmix
if ("objURLsuffix" in window) {
if ("handleURLBarCommand" in objURLsuffix)
eval("objURLsuffix.handleURLBarCommand ="+objURLsuffix.handleURLBarCommand.toString().replace(
'objURLsuffix.BrowserLoadURL(aTriggeringEvent, postData.value, altDisabled);',
'TMP_BrowserLoadURL(aTriggeringEvent, postData.value, altDisabled);'
).replace(
'objURLsuffix.BrowserLoadURL(aTriggeringEvent, postData.value);',
'TMP_BrowserLoadURL(aTriggeringEvent, postData.value, true);'
));
if ("canonizeUrl" in objURLsuffix)
eval("objURLsuffix.canonizeUrl ="+objURLsuffix.canonizeUrl.toString().replace(
'return [gURLBar.value, aPostDataRef];',
'return [gURLBar.value, aPostDataRef, true];'
));
window.handleURLBarCommand = objURLsuffix.handleURLBarCommand;
}
if ("TreeStyleTabBrowser" in window) {
// TreeStyleTabBrowser replace boxObject.x to boxObject.y but we change boxObject.x to boxObject.screenX
function replaceHorizontalProps(aString) {
return aString.replace(
/boxObject\.screenX/g,
'boxObject[screenPosProp]'
).replace(
'{',
'{var screenPosProp = gBrowser.treeStyleTab.isVertical ? "screenY" : "screenX" ;'
)
}
if (!TreeStyleTabService.getTreePref('TMP.doNotUpdate.isTabVisible'))
eval('gBrowser.mTabContainer.isTabVisible = '+
replaceHorizontalProps(gBrowser.mTabContainer.isTabVisible.toSource()));
eval('gBrowser.mTabContainer.ensureTabIsVisible = '+
replaceHorizontalProps(gBrowser.mTabContainer.ensureTabIsVisible.toSource().replace()));
/*
* TST have eval to TMP_Bookmark.openGroup
* we replace TMP_Bookmark.openGroup with TMP_Places.openGroup at Tabmix 0.3.8.2pre.090830
* we also replace call to TreeStyleTabService.openGroupBookmarkBehavior();
* with aOpenGroupBookmarkBehavior that we pass from PlacesUIUtils._openTabset
* we only call this functiom from browserWindow so we don't need to call it for
* other places windows
*/
eval("TMP_Places.openGroup ="+TMP_Places.openGroup.toString().replace(
/(function[^\(]*\([^\)]+)(\))/,
'$1, TSTOpenGroupBookmarkBehavior$2'
).replace(
'{',
'{if (TSTOpenGroupBookmarkBehavior == null) TSTOpenGroupBookmarkBehavior = TreeStyleTabService.openGroupBookmarkBehavior();'
).replace(
'index = prevTab._tPos + 1;',
<![CDATA[
index = gBrowser.treeStyleTab.getNextSiblingTab(gBrowser.treeStyleTab.getRootTab(prevTab));
if (tabToSelect == aTab) index = gBrowser.treeStyleTab.getNextSiblingTab(index);
index = index ? index._tPos : (prevTab._tPos + 1);
]]>
).replace(
/(prevTab = aTab;)/,
<![CDATA[
$1
if (tabToSelect == aTab && TSTOpenGroupBookmarkBehavior & TreeStyleTabService.kGROUP_BOOKMARK_SUBTREE) {
TreeStyleTabService.readyToOpenChildTab(tabToSelect, true, gBrowser.treeStyleTab.getNextSiblingTab(tabToSelect));
}
]]>
).replace(
/(tabBar.nextTab)/,
<![CDATA[
if (TSTOpenGroupBookmarkBehavior & TreeStyleTabService.kGROUP_BOOKMARK_SUBTREE)
TreeStyleTabService.stopToOpenChildTab(tabToSelect);
$1]]>
));
// the hack in tree style tab code is obsolete
var fn = TMP_openMultipleLinks.toString();
fn = fn.split("return true;");
fn[fn.length-2] += "if (!check) { TreeStyleTabService.stopToOpenChildTab(focusedWindow); };\n"
eval("TMP_openMultipleLinks ="+fn.join("return true;").replace(
'while (nextEpisode != null)',
'if (!check) TreeStyleTabService.readyToOpenChildTab(focusedWindow, true); \
$&'
));
eval("TreeStyleTabBrowser.prototype.onTabClick ="+TreeStyleTabBrowser.prototype.onTabClick.toString().replace(
'var tab = this.getTabFromTabbarEvent(aEvent);',
'$& \
if (!tab) return;'
));
if("bookmarkMultipleTabs" in window['piro.sakura.ne.jp']) {
eval("window['piro.sakura.ne.jp'].bookmarkMultipleTabs.addBookmarkTabsFilter ="+window['piro.sakura.ne.jp'].bookmarkMultipleTabs.addBookmarkTabsFilter.toString().replace(
'return aTab.linkedBrowser.currentURI;',
'var browser = aTab.linkedBrowser; \
var uri = browser.currentURI; \
return {uri: uri, title: TMP_Places.getTabFixedTitle(browser, uri)};'
));
}
}
/* fast dial FdUtils*/
if ("FdUtils" in window && FdUtils.whereToOpenLink) {
eval("FdUtils.whereToOpenLink ="+FdUtils.whereToOpenLink.toString().replace(
'if (e.ctrlKey)',
'if (e.ctrlKey || TMP_whereToOpen(null).lock)'
));
}
// with MR Tech's local install extention
// don't open trober in current tab when tab is locked
// or trober is to diffrent site then the current
if (typeof(Local_Install) == "object")
eval("Local_Install.openThrobber ="+Local_Install.openThrobber.toString().replace(
'local_common.openURL(local_common.getThrobberURL(), inNewTab);',
'var url = local_common.getThrobberURL(); \
local_common.openURL(url, inNewTab ? inNewTab : TMP_checkCurrent(url) == "tab");'
));
// unable to close surce tab after duplicate with FireGestures esextension
if ("FireGestures" in window)
eval("FireGestures._performAction ="+FireGestures._performAction.toString().replace(
'gBrowser.moveTabTo(newTab, ++orgTab._tPos);',
'gBrowser.moveTabTo(newTab, orgTab._tPos + 1);'
));
gBrowser.TMP_openTabNext = function _TMP_openTabNext(aTab, aCaller) {
var blockedCallers = {sss_restoreWindow:true, ct_SSS_undoCloseTab:true, TMP_BrowserOpenTab:true};
if (aCaller in blockedCallers)
return;
// the fix in TreeStyleTabBrowser 0.8.2009073102 hacks.js make new tab open in wrong place
// when tab don't have Child tabs
if (this.mPrefs.getBoolPref("extensions.tabmix.openTabNext")) {
this.TMmoveTabTo(aTab, this.mCurrentTab._tPos + this.mTabContainer.nextTab,1);
if (this.mPrefs.getBoolPref("extensions.tabmix.openTabNextInverse"))
this.mTabContainer.nextTab++;
}
}
gBrowser.TMmoveTabTo = function _TMmoveTabTo(aTab, aIndex, flag) {
if ( aTab._tPos == aIndex )
return aTab;
if(!(flag & 1)) this.mTabContainer.nextTab = 1;
this._browsers = null; // invalidate cache
this.mTabFilters.splice(aIndex,0,this.mTabFilters.splice(aTab._tPos, 1)[0]);
this.mTabListeners.splice(aIndex,0,this.mTabListeners.splice(aTab._tPos, 1)[0]);
var tabCount = this.mTabContainer.childNodes.length;
var newPos = tabCount - 1 < aIndex ? tabCount - 1 : aIndex;
var oldPosition = aTab._tPos;
aIndex = aIndex < aTab._tPos ? aIndex: aIndex+1;
this.mCurrentTab._selected = false;
// use .item() instead of [] because dragging to the end of the strip goes out of
// bounds: .item() returns null (so it acts like appendChild), but [] throws
this.mTabContainer.insertBefore(aTab, this.mTabContainer.childNodes.item(aIndex));
// invalidate cache, because mTabContainer is about to change
this._browsers = null;
var i;
for (i = 0; i < tabCount; i++) {
this.mTabContainer.childNodes[i]._tPos = i;
this.mTabContainer.childNodes[i]._selected = false;
}
this.mCurrentTab._selected = true;
var evt = document.createEvent("UIEvents");
evt.initUIEvent("TabMove", true, false, window, oldPosition);
aTab.dispatchEvent(evt);
SessionManager.tabMoved(aTab, oldPosition, newPos);
this.mTabContainer.ensureTabIsVisible(aTab._tPos);
return aTab;
}
gBrowser.duplicateTab = function tabbrowser_duplicateTab(aTab, aHref, aTabData, disallowSelect) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
var newTab = null;
// try to have SessionStore duplicate the given tab
newTab = this.SSS_duplicateTab(aTab, aHref, aTabData);
if(!newTab && aTabData)
throw new Error("Tabmix was unable to restore closed tab to new window");
// if SSS_duplicateTab failed fall back to TMP_duplicateTab
if(!newTab)
newTab = this.TMP_duplicateTab(aTab, aHref);
content.focus();
var bgPref = this.mPrefs.getBoolPref("extensions.tabmix.loadDuplicateInBackground");
var copyToNewWindow = window != aTab.ownerDocument.defaultView;
if (!disallowSelect && !bgPref) {
newTab.owner = copyToNewWindow ? null : aTab;
this.TMP_selectNewForegroundTab(newTab, bgPref, aHref || this.getBrowserForTab(aTab).currentURI.spec, false);
}
if (!disallowSelect && !copyToNewWindow && this.mPrefs.getBoolPref("extensions.tabmix.openDuplicateNext")) {
var pos = newTab._tPos > aTab._tPos ? 1 : 0;
this.TMmoveTabTo(newTab, aTab._tPos+pos);
}
return newTab;
}
gBrowser.SSS_duplicateTab = function tabbrowser_SSS_duplicateTab(aTab, aHref, aTabData) {
var newTab = null;
try {
var newTab, tabState;
// add new history entry after current index, and removing forword history
function addNewHistoryEntry() {
var activeIndex = (tabState.index || tabState.entries.length) - 1;
var entriesToRemove = tabState.entries.length - tabState.index;
var newEntry = { url: aHref }; // we don't know the page title at this moment
tabState.entries.splice(activeIndex + 1 , entriesToRemove, newEntry);
tabState.index++;
}
// we need to update history title after the new page loaded for use in back/forword button
var self = this;
function updateNewHistoryTitle(aEvent) {
this.removeEventListener("load", updateNewHistoryTitle, true);
var history = this.webNavigation.sessionHistory;
var shEntry = history.getEntryAtIndex(history.index, false).QueryInterface(Ci.nsISHEntry);
shEntry.setTitle(self.getTabForBrowser(this).label);
}
var ss = Cc["@mozilla.org/browser/sessionstore;1"]
.getService(Ci.nsISessionStore);
tabState = aTabData ? aTabData.state : eval("(" + ss.getTabState(aTab) + ")");
TMP_SessionStore.removeWyciwyg(tabState);
newTab = this.addTab("about:blank");
if (aHref) {
addNewHistoryEntry();
this.getBrowserForTab(newTab).addEventListener("load", updateNewHistoryTitle, true);
}
ss.setTabState(newTab, tabState.toSource());
} catch (ex) {TMP_ASSERT(ex);}
return newTab;
}
gBrowser.TMP_duplicateTab = function tabbrowser_TMP_duplicateTab(aTab, href) {
try {
var aBrowser = this.getBrowserForTab(aTab);
var originalHistory = aBrowser.webNavigation.sessionHistory;
var newTab = this.addTab("about:blank");
var newBrowser = this.getBrowserForTab(newTab);
var prop = SessionData.getTabProperties(aTab);
SessionData.setTabProperties(newTab, prop);
newBrowser.addEventListener('load', dupScrollPosition, true);
//save scroll data and href to load after we clone tab history
var bContent = aBrowser.contentWindow;
newBrowser._scrollData = {
href: href,
_scrollX: bContent.scrollX,
_scrollY: bContent.scrollY
};
dtMergeWindows.cloneTabHistory(newBrowser.webNavigation, dtMergeWindows.copyHistory(originalHistory));
} catch (ex) {TMP_ASSERT(ex);}
return newTab;
}
gBrowser.duplicateInWindow = function (aTab, aMoveTab, aTabData) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
if (gSingleWindowMode) {
if (!aMoveTab)
this.duplicateTab(aTab, null, aTabData);
return;
}
if (gIsFirefox35 && aMoveTab) {
this.replaceTabWithWindow(aTab);
return;
}
function _restoreWindow(aWindow, aCount) {
// use getBrowser() for Firefox 3.0
var tabBrowser = aWindow.getBrowser();
// make sure sessionHistory is ready
try {
if (!tabBrowser.webNavigation.sessionHistory) {
throw new Error();
}
}
catch (ex) { // in case browser or history aren't ready yet
if (aCount < 10) {
var restoreHistoryFunc = function() {_restoreWindow(aWindow, aCount + 1); }
aWindow.setTimeout(restoreHistoryFunc, 100);
return;
}
}
var oldTab = aWindow._duplicateData.tab;
var tabData = aWindow._duplicateData.tabData;
var sourceWindow = aWindow.opener;
// we don't have to do anything if the openr not exist, or we copy only tabdata
var moveMode = aWindow._duplicateData.move && sourceWindow && !tabData;
if (moveMode) {
var sourceBrowser = sourceWindow.gBrowser;
}
// remove unused blank tab
var blankTabToRemove = null;
if (tabBrowser.isBlankNotBusyTab(tabBrowser.mCurrentTab)) {
blankTabToRemove = tabBrowser.mCurrentTab;
blankTabToRemove.collapsed = true;
}
var newTab = tabBrowser.duplicateTab(oldTab, null, tabData);
if (blankTabToRemove)
tabBrowser.removeTab(blankTabToRemove);
// make sure the new tab is in the end
var lastIndex = tabBrowser.mTabContainer.childNodes.length - 1;
if (newTab._tPos < lastIndex)
tabBrowser.moveTabTo(newTab, lastIndex);
// remove old tab and close the other window if _duplicateTab was its last tab
if (moveMode) {
var needToClose = "needToClose" in sourceWindow;
if (oldTab.parentNode) { // make sure the tab still exist before we try to remove it
needToClose = needToClose || sourceBrowser.mTabContainer.childNodes.length == 1;
oldTab.removeAttribute("protected");
sourceBrowser.removeTab(oldTab);
}
if (needToClose)
sourceWindow.closeWindow(true);
}
delete newWindow._duplicateData;
}
// we going to delete the moved tab after some timeout catch the flag now
// we use this only if the tab was not exist anymore when its time to remove it
if (aMoveTab && this.mTabContainer.childNodes.length == 1)
window.needToClose = true;
// open new window
var newWindow = window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no");
newWindow.tabmix_afterTabduplicated = true;
newWindow._duplicateData = {tab: aTab, tabData: aTabData, move: aMoveTab};
newWindow.addEventListener("load", function (aEvent) {
var win = aEvent.currentTarget;
win.removeEventListener("load", arguments.callee, false);
// make sure sessionstore is init
try {
var ss = Cc["@mozilla.org/browser/sessionstore;1"].
getService(Ci.nsISessionStore);
ss.init(win);
} catch(ex) {
dump("nsSessionStore could not be initialized: " + ex + "\n");
return;
}
_restoreWindow(win, 0);
}, false);
}
gBrowser.openLinkWithHistory = function (aTab) {
var url = gContextMenu.linkURL;
if (!isValidUrl(url))
url = null;
var newTab = this.duplicateTab(aTab, url, null, url == null);
if (!url) {
try {
// flip aTab with newTab
// and dispatch click event on the link....
newTab.removeAttribute("busy");
this.setIcon(newTab, this.getBrowserForTab(aTab).mIconURL);
newTab.label = aTab.label;
newTab.width = aTab.width;
var index = newTab._tPos;
this.TMmoveTabTo(newTab, aTab._tPos);
var pos = index > aTab._tPos ? 1 : 0;
this.TMmoveTabTo(aTab, index + pos);
if (this.mPrefs.getBoolPref("extensions.tabmix.loadDuplicateInBackground")) {
this.selectedTab = newTab;
aTab.removeAttribute("visited");
aTab.removeAttribute("flst_id");
}
else {
aTab.owner = newTab;
this.selectedTab = aTab;
newTab.setAttribute("flst_id", new Date().getTime());
newTab.setAttribute("visited", true);
newTab.setAttribute("dontremovevisited", true);
aTab.setAttribute("flst_id", new Date().getTime());
}
var event = document.createEvent("Events");
event.initEvent("click", true, true);
event.getPreventDefault = function () { return false; }
gContextMenu.target.dispatchEvent(event);
newTab = aTab;
}
catch (ex) {TMP_ASSERT(ex);}
}
return newTab;
}
gBrowser.openHereWith = function () {
var url = gContextMenu.linkURL;
if (!isValidUrl(url))
return;
openUILinkIn(gContextMenu.linkURL, "current", null, null, gContextMenu.target.ownerDocument.documentURIObject);
}
gBrowser.openInverseLink = function () {
var url = gContextMenu.linkURL;
if (!isValidUrl(url))
return null;
// aTab is for treeStyleTab extension look in treeStyleTab hacks.js
var aTab = this.selectedTab;
var bgPref = this.mPrefs.getBoolPref("browser.tabs.loadInBackground");
var newTab = this.loadOneTab(url, null, null, null, !bgPref, true);
if (url == "about:blank")
setURLBarFocus();
return newTab;
}
window.isValidUrl = function (aUrl) {
// valid urls don't contain spaces ' '; if we have a space it isn't a valid url.
// Also disallow dropping javascript: or data: urls--bail out
if (!aUrl || !aUrl.length || aUrl.indexOf(" ", 0) != -1 ||
/^\s*(javascript|data):/.test(aUrl))
return false;
return true;
}
gBrowser.closeAllTabs = function TMP_closeAllTabs() {
if (this.warnAboutClosingTabs("All")) {
var childNodes = this.mTabContainer.childNodes;
if (this.mTabContainer.collapsedTabs > 0)
this.mTabContainer.collapsedTabs = 0;
for (var i = childNodes.length - 1; i >= 0; --i) {
if (childNodes[i] != this.mCurrentTab)
this.removeTab(childNodes[i], true);
}
this.removeTab(this.mCurrentTab, true);
// _handleTabSelect will call ensureTabIsVisible
}
}
gBrowser.closeGroupTabs = function TMP_closeGroupTabs(aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
var URL = this.getBrowserForTab(aTab).currentURI.spec;
var matches = URL.match(/(^.*\/)(.*)/);
var aDomain = matches ? matches[1] : URL;
if (this.warnAboutClosingTabs("Group", null, null, aDomain)) {
var childNodes = this.mTabContainer.childNodes;
if (this.mTabContainer.collapsedTabs > 0)
this.mTabContainer.collapsedTabs = 0;
for (var i = childNodes.length - 1; i > -1; --i) {
if (childNodes[i] != aTab &&
this.getBrowserForTab(childNodes[i]).currentURI.spec.indexOf(aDomain) != -1)
this.removeTab(childNodes[i], true);
}
this.removeTab(aTab, true);
this.mTabContainer.ensureTabIsVisible(this.mTabContainer.selectedIndex);
}
}
gBrowser.closeRightTabs = function (aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
if (this.warnAboutClosingTabs("Right", aTab._tPos)) {
if ( aTab._tPos < this.mCurrentTab._tPos )
this.mTabContainer.selectedItem = aTab;
var childNodes = this.mTabContainer.childNodes;
for (var i = childNodes.length - 1; i > aTab._tPos; i-- )
this.removeTab(childNodes[i], true);
}
}
gBrowser.closeLeftTabs = function TMP_closeLeftTabs(aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
if (this.warnAboutClosingTabs("Left", aTab._tPos)) {
if ( aTab._tPos > this.mCurrentTab._tPos ) {
this.mTabContainer.selectedItem = aTab;
}
this.mTabContainer.ensureTabIsVisible(this.mTabContainer.selectedIndex);
var childNodes = this.mTabContainer.childNodes;
if (this.mTabContainer.collapsedTabs > 0)
this.mTabContainer.collapsedTabs = 0;
for (var i = aTab._tPos - 1; i >= 0; i-- )
this.removeTab(childNodes[i], true);
}
}
gBrowser.removeAllTabsBut = function TMP_removeAllTabsBut(aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
if (this.warnAboutClosingTabs("AllBut", null, aTab.hasAttribute("protected"))) {
if (aTab != this.mCurrentTab) {
this.mTabContainer.selectedItem = aTab;
}
this.mTabContainer.ensureTabIsVisible(this.mTabContainer.selectedIndex);
var childNodes = this.mTabContainer.childNodes;
if (this.mTabContainer.collapsedTabs > 0)
this.mTabContainer.collapsedTabs = 0;
for (var i = childNodes.length - 1; i >= 0; --i) {
if (childNodes[i] != aTab)
this.removeTab(childNodes[i], true);
}
}
}
gBrowser.reloadLeftTabs = function (aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
var childNodes = this.mTabContainer.childNodes;
if ( aTab._tPos > this.mCurrentTab._tPos )
this.mTabContainer.selectedItem = aTab;
for (var i = aTab._tPos - 1; i >= 0; i-- ) {
try {
this.getBrowserForTab(childNodes[i]).reload();
} catch (e) { }
}
}
gBrowser.reloadRightTabs = function (aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
var childNodes = this.mTabContainer.childNodes;
if ( aTab._tPos < this.mCurrentTab._tPos )
this.mTabContainer.selectedItem = aTab;
for (var i = childNodes.length - 1; i > aTab._tPos; i-- ) {
try {
this.getBrowserForTab(childNodes[i]).reload();
} catch (e) { }
}
}
gBrowser.reloadAllTabsBut = function (aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
else
this.mTabContainer.selectedItem = aTab;
var childNodes = this.mTabContainer.childNodes;
for (var i = childNodes.length - 1; i >= 0; --i) {
if (childNodes[i] == aTab)
continue;
try {
this.getBrowserForTab(childNodes[i]).reload();
} catch (e) { }
}
}
// we keep this function to saty compatible with other extensions that use it
gBrowser.undoRemoveTab = function () {
TMP_ClosedTabs.undoCloseTab();
}
gBrowser.delayUndoRemoveAllTab = function () {
// call undoRemoveAllTab after delay to let the popup menu time to hide
var _this = this;
window.setTimeout( function () { _this.undoRemoveAllTab(); }, 0 );
}
gBrowser.undoRemoveAllTab = function () {
if (!PlacesController.prototype._confirmOpenTabs(this.closedTabs.length))
return;
var aTab, blankTab, newTab, selectTab = true;
// catch blank tab for reuse
var blankTabs = [];
for (var i = 0; i < this.mTabs.length ; i++) {
aTab = this.mTabs[i];
if (this.isBlankNotBusyTab(aTab)) {
aTab.reuse = true;
blankTabs.push(aTab);
}
}
while (this.closedTabs.length > 0) {
aTab = getClosedTab("original", 0);
blankTab = blankTabs.pop();
newTab = (blankTab) ? blankTab : this.addTab("about:blank");
this.restoreTabData(newTab, aTab.pos, aTab.history, aTab.properties, aTab.scroll, selectTab);
selectTab = false;
// for TreeStyleTab extension
if ("TreeStyleTabBrowser" in window && this.treeStyleTab && this.treeStyleTab.useTMPSessionAPI)
this.treeStyleTab.onTabRestored({ target : newTab, originalTarget : newTab });
}
// remove unused blank tabs
while(blankTabs.length > 0){
blankTab = blankTabs.pop();
this.removeTab(blankTab);
}
this.mTabContainer.nextTab = 1
}
gBrowser.restoreTab = function tabbrowser_restoreTab(ord, hist, prop, zoom) {
// reuse blanke tab
var newTab = this.selectedTab;
if (!newTab.parentNode || !this.isBlankNotBusyTab(newTab))
newTab = this.addTab("about:blank");
this.restoreTabData(newTab, ord, hist, prop, zoom, true);
return newTab;
}
gBrowser.restoreTabData = function tabbrowser_restoreTabData(newTab, ord, hist, prop, zoom, selectTab) {
var newBrowser = this.getBrowserForTab(newTab);
var restorePosition = this.mPrefs.getBoolPref("extensions.tabmix.undoClosePosition");
var newPos;
var lastIndex = this.mTabContainer.childNodes.length - 1;
if ( restorePosition ) {
newPos = ord > lastIndex ? lastIndex : ord;
this.TMmoveTabTo(newTab, newPos);
}
else if (newTab.reuse) {
// move reuse tabs to the end when restore all closed tabs list
var openTabNext = this.mPrefs.getBoolPref("extensions.tabmix.openTabNext");
newPos = openTabNext ? this.mCurrentTab._tPos + this.mTabContainer.nextTab++ : lastIndex;
this.TMmoveTabTo(newTab, newPos, 1);
if (newTab != this.mCurrentTab)
newTab.removeAttribute("flst_id");
delete newTab.reuse;
}
SessionData.setTabProperties(newTab, prop);
var oldHistory = hist;
var newHistory = newBrowser.webNavigation.sessionHistory;
// reset old history
if (newHistory.count > 0) {
newHistory.PurgeHistory(newHistory.count);
}
newHistory.QueryInterface(Components.interfaces.nsISHistoryInternal);
for (var i = 0; i < oldHistory.count; i++) {
newHistory.addEntry(oldHistory.getEntryAtIndex(i, false), true);
}
if( oldHistory.count ) {
try { newBrowser.webNavigation.gotoIndex(oldHistory.index); } catch (e) {}
}
// call to set scroll Position for restored closed tab from prev session
if (zoom && zoom != "0,0,1") {
newBrowser.addEventListener('load', dupScrollPosition, true);
newBrowser._scrollData = {
href: null,
_scrollX: XYZ[0],
_scrollY: XYZ[1]
}
}
if (selectTab) {
this.selectedTab = newTab;
// focus the tab's content area
setTimeout(function(_content) { _content.focus(); }, 0, newBrowser.contentWindow);
}
return newTab;
}
gBrowser.lockTab = function (aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
if ( aTab.hasAttribute("locked") ) {
aTab.removeAttribute("locked");
aTab.setAttribute("_locked", "false");
}
else {
aTab.setAttribute("locked", "true");
aTab.setAttribute("_locked", "true");
}
SessionManager.updateTabProp(aTab);
}
gBrowser.protectTab = function (aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
if ( aTab.hasAttribute("protected") )
aTab.removeAttribute("protected");
else
aTab.setAttribute("protected", "true");
SessionManager.updateTabProp(aTab);
}
gBrowser.freezeTab = function (aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
if ( !aTab.hasAttribute("protected") || !aTab.hasAttribute("locked")){
aTab.setAttribute("protected", "true");
aTab.setAttribute("locked", "true");
aTab.setAttribute("_locked", "true");
} else {
aTab.removeAttribute("protected");
aTab.removeAttribute("locked");
aTab.setAttribute("_locked", "false");
}
SessionManager.updateTabProp(aTab);
}
gBrowser.SelectToMerge = function(aTab) {
if (gSingleWindowMode && numberOfWindows() == 1) return;
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
if (aTab.hasAttribute("mergeselected")) {
aTab.removeAttribute("mergeselected");
aTab.label = aTab.label.substr(4);
} else {
aTab.setAttribute("mergeselected", "true")
aTab.label = "(*) "+aTab.label;
}
if (gWidthFitTitle) {
tabBarScrollStatus();
checkBeforeAndAfter();
}
}
gBrowser.onSetReloadTime = function(aTab, aReloadTime) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
aTab.autoReloadTime = aReloadTime;
this.mPrefs.setIntPref("extensions.tabmix.reload_time", aTab.autoReloadTime);
this.enableAutoReload(aTab);
}
gBrowser.onAutoReloadEnable = function (aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
if (aTab.autoReloadEnabled)
this.disableAutoReload(aTab);
else
this.enableAutoReload(aTab);
}
gBrowser.enableAutoReload = function(aTab) {
var url = this.getBrowserForTab(aTab).currentURI.spec
if (url.match(/^about:/))
return;
aTab.autoReloadEnabled = true;
aTab.autoReloadURI = url;
clearTimeout(aTab.autoReloadTimerID);
aTab.autoReloadTimerID = setTimeout(reloadPage, aTab.autoReloadTime*1000, aTab);
aTab.setAttribute("reload-data", aTab.autoReloadURI + " " + aTab.autoReloadTime);
}
gBrowser.disableAutoReload = function (aTab) {
aTab.autoReloadEnabled = false;
aTab.autoReloadURI = null;
aTab.postDataAcceptedByUser = false;
clearTimeout(aTab.autoReloadTimerID);
aTab.removeAttribute("reload-data");
}
gBrowser.onEnableAutoReloadAllTabs = function () {
var tabs = this.mTabContainer.childNodes;
for(var i=0; i<tabs.length; i++){
var tab = tabs[i];
if (tab.autoReloadEnabled == null)
setupAutoReload(tab);
if (!tab.autoReloadEnabled || tab.autoReloadURI != this.getBrowserForTab(tab).currentURI.spec)
this.enableAutoReload(tab);
}
}
gBrowser.onDisableAutoReloadAllTabs = function () {
var tabs = this.mTabContainer.childNodes;
for(var i=0; i<tabs.length; i++){
var tab = tabs[i];
if (tab.autoReloadEnabled)
this.disableAutoReload(tab);
}
}
gBrowser.onAutoReloadCustom = function(aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
window.openDialog('chrome://tabmixplus/content/minit/autoReload.xul', '_blank', 'chrome,modal,centerscreen', autoReloadDialogResult);
if (gAutoReloadDialogAccepted) {
aTab.autoReloadTime = this.mPrefs.getIntPref("extensions.tabmix.custom_reload_time");
this.enableAutoReload(aTab);
}
}
gBrowser.onTabReloaded = function(aTab, aBrowser) {
if (aTab.autoReloadTimerID)
clearTimeout(aTab.autoReloadTimerID);
if (aTab.autoReloadURI == aBrowser.currentURI.spec) {
if (aBrowser.curScrollX || aBrowser.curScrollY)
aBrowser.contentWindow.scrollTo(aBrowser.curScrollX, aBrowser.curScrollY);
if (!aTab.autoReloadEnabled)
aTab.autoReloadEnabled = true;
aTab.autoReloadTimerID = setTimeout(reloadPage, aTab.autoReloadTime*1000, aTab);
}
else if (aTab.autoReloadEnabled)
aTab.autoReloadEnabled = false;
}
gBrowser.copyTabUrl = function (aTab) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
var URL = this.getBrowserForTab(aTab).contentDocument.location;
var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
clipboard.copyString(URL);
}
gBrowser.renameTab = function(aTab) {
if (aTab.localName != "tab") aTab = this.mCurrentTab;
var browser = this.getBrowserForTab(aTab);
var url = browser.contentDocument.baseURI || browser.currentURI.spec;
var docTitle = getTitleFromBookmark(url, browser.contentDocument.title, aTab.getAttribute("tabmix_bookmarkId"))
|| this.mStringBundle.getString("tabs.untitled");
var tabTitle;
if (aTab.getAttribute("label-uri") == url || aTab.getAttribute("label-uri") == "*")
tabTitle = aTab.getAttribute("fixed-label");
else
tabTitle = docTitle;
var data = {
value: tabTitle,
rename_all: this._renameAll != null ? this._renameAll : this.mPrefs.getBoolPref("extensions.tabmix.titlefrombookmark"),
permanently: aTab.getAttribute("label-uri") == "*",
resetTitle: false,
modified: false,
docTitle: docTitle
};
window.openDialog('chrome://tabmixplus/content/minit/setFixedLabel.xul', '_blank', 'chrome,modal,centerscreen', data);
this._renameAll = data.rename_all;
if (data.modified) {
var label = data.value;
if (data.rename_all)
this.setFixLabel(label, url, !data.resetTitle && data.value != docTitle);
else {
var resetDefault = data.resetTitle || (data.value == docTitle && !data.permanently);
TMP_setItem(aTab, "fixed-label", resetDefault ? null : label);
var _url = resetDefault ? null : data.permanently ? "*" : url;
TMP_setItem(aTab, "label-uri", _url);
SessionManager.updateTabProp(aTab);
if (aTab.getAttribute('label') != label) {
aTab.setAttribute('label', label);
if (gWidthFitTitle) {
tabBarScrollStatus();
checkBeforeAndAfter();
}
if (aTab == this.mCurrentTab)
this.updateTitlebar();
}
}
}
}
gBrowser.setFixLabel = function (label, url, setFixedLabel) {
// if setFixedLabel is false we reset title to default
var i, wnd, aTab, browser, enumerator = windowEnumerator(), titleChanged = false;
while (enumerator.hasMoreElements()) {
wnd = enumerator.getNext();
for (i = 0; i < wnd.gBrowser.mTabs.length; i++) {
aTab = wnd.gBrowser.mTabs[i];
browser = wnd.gBrowser.getBrowserForTab(aTab);
if (browser.currentURI.spec == url) {
wnd.TMP_setItem(aTab, "fixed-label", setFixedLabel ? label : null);
wnd.TMP_setItem(aTab, "label-uri", setFixedLabel ? url : null);
wnd.SessionManager.updateTabProp(aTab);
if (aTab.getAttribute('label') != label) {
titleChanged = true;
aTab.setAttribute('label', label);
if (aTab == wnd.gBrowser.mCurrentTab)
wnd.gBrowser.updateTitlebar();
}
}
}
if (titleChanged && gWidthFitTitle) {
wnd.tabBarScrollStatus();
wnd.checkBeforeAndAfter();
}
}
}
gBrowser.previousTabIndex = function _previousTabIndex(aTab) {
var temp_id, tempIndex = -1, max_id = 0;
var items = this.mTabContainer.getElementsByAttribute("flst_id", "*");
for (var i = 0; i < items.length; ++i ) {
temp_id = items[i].getAttribute("flst_id");
if (aTab && items[i] == aTab)
continue;
if ( temp_id && temp_id > max_id ) {
max_id = temp_id;
tempIndex = items[i]._tPos;
}
}
return tempIndex;
}
gBrowser.previousTab = function (aTab) {
if (this.mTabs.length == 1) return;
var tempIndex = this.previousTabIndex(aTab);
// if no flst_id go to previousTab tab, from first tab go to the next tab
if (tempIndex == -1)
tempIndex = aTab._tPos == 0 ? 1 : aTab._tPos - 1;
this.selectedTab = this.mTabs[tempIndex];
if (gIsFirefox36)
this.selectedBrowser.focus();
else
focusElement(content);
}
gBrowser.selectIndexAfterRemove = function (oldTab) {
var currentIndex = this.mCurrentTab._tPos;
if (this.mCurrentTab != oldTab)
return currentIndex;
var l = this.mTabs.length;
if (l==1)
return 0;
var mode = this.mPrefs.getIntPref("extensions.tabmix.focusTab");
switch ( mode ) {
case 0: // first tab
return currentIndex == 0 ? 1 : 0;
break;
case 1: // left tab
return currentIndex == 0 ? 1 : currentIndex-1 ;
break;
case 3: // last tab
return currentIndex == l - 1 ? currentIndex - 1 : l - 1;
break;
case 6: // last opened
var lastTab = this.getTabForLastPanel();
if (lastTab == oldTab && l > 1) {
lastTab = document.getAnonymousElementByAttribute(this, "linkedpanel",
this.mPanelContainer.childNodes[l-2].id);
}
return lastTab._tPos;
case 4: // last selected
var tempIndex = this.previousTabIndex(oldTab);
// if we don't find last selected we fall back to default
if (tempIndex > -1)
return tempIndex;
case 2: // opener / right (default )
case 5: // right tab
default:
if (mode != 5 && this.mPrefs.getBoolPref("browser.tabs.selectOwnerOnClose") && "owner" in oldTab) {
var owner = oldTab.owner;
if (owner && owner.parentNode && owner != oldTab)
// oldTab and owner still exist just return its position
return owner._tPos;
}
}
return currentIndex == l - 1 ? currentIndex - 1 : currentIndex + 1;
}
gBrowser.closeTab = function(aTab) {
// throws exception when rapid click on close tab button
// we call this after delay
if (!aTab.parentNode) return;
if (this.mTabContainer.childNodes.length == 1 && this.isBlankNotBusyTab(aTab) &&
!this.mPrefs.getBoolPref("extensions.tabmix.keepLastTab")) {
var urlBar = document.getElementById("urlbar");
if (urlBar) {
urlBar.value = "";
urlBar.focus();
}
}
else {
// clear all timeouts before we remove the tab
if (aTab.isClosing) clearTimeout(aTab.isClosing);
if (aTab.mSelect) clearTimeout(aTab.mSelect);
if (aTab.mouseHoverSelect && aTab.mFocusId) {
clearTimeout(aTab.mFocusId);
}
if (aTab.mButtonId) clearTimeout(aTab.mButtonId);
if (aTab.hasAttribute("busy"))
this.getBrowserForTab(aTab).stop();
this.removeTab(aTab, true);
if (this.mTabContainer.childNodes.length == 1 && this.isBlankTab(this.mCurrentTab))
setURLBarFocus();
this.stopMouseHoverSelect(aTab);
}
}
gBrowser.stopMouseHoverSelect = function(aTab) {
// add extra delay after tab removed or after tab flip before we select by hover
// to let the user time to move the mouse
if (aTab.mouseHoverSelect) {
function removeDelayAfterClose(browser) {
browser.removeAttribute("preventMouseHoverSelect");
}
this.setAttribute("preventMouseHoverSelect",true);
var delay = aTab.mouseHoverSelectDelay + 50;
setTimeout(removeDelayAfterClose, delay, this);
}
}
gBrowser.warnAboutClosingTabs = function (whatToClose, tabPos, protectedTab, aDomain) {
// try to cach call from other extensions to warnAboutClosingTabs
if (typeof(whatToClose) == "boolean") {
if (!whatToClose)
protectedTab = this.mCurrentTab.hasAttribute("protected");
whatToClose = whatToClose ? "All_onExit" : "AllBut";
}
var childNodes = this.mTabContainer.childNodes;
var numTabs = childNodes.length;
// calc the number of tab to close when there is protected tabs.
var protectedTabs = this.mTabContainer.getElementsByAttribute("protected", true);
var numProtected = protectedTabs.length;
var shouldPrompt = 0;
var prefs = ["extensions.tabmix.tabs.warnOnClose",
"extensions.tabmix.protectedtabs.warnOnClose",
"browser.tabs.warnOnClose"];
if (whatToClose == "All_onExit") {
if (numProtected > 0 && this.mPrefs.getBoolPref(prefs[1]))
shouldPrompt = 2;
if (numTabs > 1 && this.mPrefs.getBoolPref(prefs[2]))
shouldPrompt = 3;
}
else if (numTabs > 1 && this.mPrefs.getBoolPref(prefs[0]))
shouldPrompt = 1;
if (shouldPrompt == 0)
return true;
var i, tabsToClose = 0;
switch (whatToClose) {
case "All":
tabsToClose = numTabs - numProtected;
break;
case "All_onExit":
tabsToClose = numTabs;
break;
case "AllBut":
if (protectedTab)
--numProtected;
tabsToClose = numTabs - 1 - numProtected;
break;
case "Group":
for ( i = numTabs - 1; i > -1; --i) {
if (this.getBrowserForTab(childNodes[i]).currentURI.spec.indexOf(aDomain) != -1 &&
!childNodes[i].hasAttribute("protected"))
tabsToClose++;
}
break;
case "Right":
for ( i = 0; i < protectedTabs.length; i++ )
if (protectedTabs[i]._tPos <= tabPos)
--numProtected;
tabsToClose = numTabs - tabPos - 1 - numProtected;
break;
case "Left":
for ( i = 0; i < protectedTabs.length; i++ )
if (protectedTabs[i]._tPos >= tabPos)
--numProtected;
tabsToClose = tabPos - numProtected;
break;
}
if (tabsToClose <= 1 && shouldPrompt < 2)
return true;
//default to true: if it were false, we wouldn't get this far
var warnOnClose = { value:true };
var bundle = this.mStringBundle;
var message, messageKey, chkBoxLabel;
var tmp_bundle = document.getElementById("tmp-string-bundle");
if (shouldPrompt == 1 || numProtected == 0) {
messageKey = (tabsToClose == 1) ? "tabs.closeWarningOneTab" : "tabs.closeWarningMultipleTabs";
message = bundle.getFormattedString(messageKey, [tabsToClose]);
chkBoxLabel = shouldPrompt == 1 ? bundle.getString("tabs.closeWarningPromptMe") :
tmp_bundle.getString("window.closeWarning.1");
}
else {
messageKey = "protectedtabs.closeWarning.";
messageKey += (numProtected < tabsToClose) ? "3" : (numProtected == 1) ? "1" : "2";
message = tmp_bundle.getFormattedString(messageKey, [tabsToClose, numProtected]);
var chkBoxKey = shouldPrompt == 3 ? "window.closeWarning.1" : "protectedtabs.closeWarning.4";
chkBoxLabel = tmp_bundle.getString(chkBoxKey);
}
var closeKey = (tabsToClose == 1) ? "tabs.closeButtonOne" : "tabs.closeButtonMultiple";
var buttonLabel = shouldPrompt == 1 ? bundle.getString(closeKey) :
tmp_bundle.getString("closeWindow.label");
window.focus();
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService);
var buttonPressed = promptService.confirmEx(window,
bundle.getString("tabs.closeWarningTitle"),
message,
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0)
+ (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
buttonLabel,
null, null,
chkBoxLabel,
warnOnClose);
var reallyClose = (buttonPressed == 0);
// don't set the pref unless they press OK and it's false
if (reallyClose && !warnOnClose.value) {
this.mPrefs.setBoolPref(prefs[shouldPrompt - 1], false);
}
return reallyClose;
}
gBrowser.TMP_selectNewForegroundTab = function (aTab, aLoadInBackground, aUrl, addOwner) {
var bgLoad = (aLoadInBackground != null) ? aLoadInBackground :
this.mPrefs.getBoolPref("browser.tabs.loadInBackground");
if (!bgLoad) {
// set new tab owner
addOwner = addOwner != null ? addOwner : true;
if (addOwner)
aTab.owner = this.selectedTab;
this.selectedTab = aTab;
if (aUrl) {
var testString = /^(about:blank|chrome:\/\/abouttab\/content\/text.html|chrome:\/\/abouttab\/content\/tab.html|chrome:\/\/google-toolbar\/content\/new-tab.html)/;
if (testString.test(aUrl))
setURLBarFocus();
}
}
}
gBrowser.getTabForBrowser = function (aBrowser) {
return document.getAnonymousElementByAttribute(this, "linkedpanel", aBrowser.parentNode.id);
}
gBrowser.getTabForLastPanel = function () {
return document.getAnonymousElementByAttribute(this, "linkedpanel", this.mPanelContainer.lastChild.id);
}
}} // end tablib
// make sure that our function don't break removeTab function
function TMP_onRemoveTab(tab, browser) {
try {
saveClosedTab(tab, browser);
TMP_ClosedTabs.setButtonDisableState();
}
catch (ex) { TMP_ASSERT(ex, "ERROR in saveClosedTab"); }
try {
SessionManager.tabScrolled(tab);
}
catch (ex) { TMP_ASSERT(ex, "ERROR in SessionManager.tabScrolled"); }
try {
SessionManager.tabClosed(tab);
}
catch (ex) { TMP_ASSERT(ex, "ERROR in SessionManager.tabClosed"); }
}
function TMP_closeLastTab() {
if (/^Mac/.test(navigator.platform) && window.location.href != getBrowserURL()) {
closeWindow(true);
return;
}
// browser.tabs.closeWindowWithLastTab exist only from Firefox 3.5
if (gBrowser.tabContainer.childNodes.length > 1 ||
!TMP_getBoolPref("", "browser.tabs.closeWindowWithLastTab",false))
gBrowser.removeCurrentTab(true);
else
closeWindow(true);
}
function TMP_closeWindow(aCountOnlyBrowserWindows) {
if (!gIsFirefox36 && !closeWindow(false))
return false;
// privatebrowsing from Firefox 3.5
var inPrivateBrowsing = false;
if (gIsFirefox35) {
try {
var pbSvc = Cc["@mozilla.org/privatebrowsing;1"]
.getService(Ci.nsIPrivateBrowsingService);
inPrivateBrowsing = pbSvc.privateBrowsingEnabled;
} catch(e) { }
}
var quitType = arguments.callee.caller.caller.name;
var showPrompt;
var windowtype = aCountOnlyBrowserWindows ? "navigator:browser" : null;
// make sure not to show here our prompt if BrowserGlue.prototype._onQuitRequest show prompt
// we save browser.startup.page in SessionManager.observe
if (!inPrivateBrowsing && !(/^Mac/.test(navigator.platform)) && numberOfWindows(false, windowtype) == 1 &&
window.document.documentElement.getAttribute("windowtype") == "navigator:browser" &&
window.gBrowser.browsers.length > 1) {
showPrompt = false;
try {
let browserStartupPref;
if ("browserStartupPref" in SessionManager) {
browserStartupPref = SessionManager.browserStartupPref;
delete SessionManager.browserStartupPref;
}
else
browserStartupPref = gTabmixPrefs.getIntPref("browser.startup.page");
var sessionWillBeSaved = browserStartupPref == 3 ||
gTabmixPrefs.getBoolPref("browser.sessionstore.resume_session_once");
if (sessionWillBeSaved || !gTabmixPrefs.getBoolPref("browser.warnOnQuit"))
showPrompt = true;
// its can't be restart here, restart don't call closeWindow in Firefox 3.0
else if (quitType == "restart")
showPrompt = !gTabmixPrefs.getBoolPref("browser.warnOnRestart");
else
showPrompt = !gTabmixPrefs.getBoolPref("browser.tabs.warnOnClose");
} catch (ex) {}
}
else
showPrompt = true;
var askBeforSave = quitType != "restartApp" && quitType != "restart";
var isLastWindow = numberOfWindows() == 1;
var result = SessionManager.deinit(isLastWindow, askBeforSave);
var canClose = result.canClose;
// we only show warnAboutClose if firefox or tabmix didn't do it already
// if showPrompt is false then prompt was shown by firefox code from BrowserGlue.prototype._onQuitRequest
// or from SessionManager.deinit
if (canClose && showPrompt && result.showMorePrompt) {
var pref = "extensions.tabmix.warnAboutClosingTabs.timeout";
var startTime = new Date().valueOf();
var oldTime = gTabmixPrefs.prefHasUserValue(pref) ? gTabmixPrefs.getCharPref(pref) : 0;
canClose = gBrowser.warnAboutClosingTabs("All_onExit");
gTabmixPrefs.setCharPref(pref, oldTime*1 + (new Date().valueOf() - startTime));
}
SessionManager.windowIsClosing(canClose, isLastWindow, result.saveSession, result.removeClosedTabs);
return canClose;
}
function TMP_contentAreaOnDrop(aEvent, aUri, aPostData) {
var where;
var browser = gBrowser.getBrowserForDocument(aEvent.target.ownerDocument);
if (browser && aUri != browser.currentURI.spec) {
var tab = gBrowser.getTabForBrowser(browser);
var isCopy = "dataTransfer" in aEvent ? (aEvent.dataTransfer.dropEffect == "copy") : (aEvent.ctrlKey || aEvent.metaKey);
if (!isCopy && tab.getAttribute("locked") &&
!gBrowser.isBlankNotBusyTab(tab) && !isUrlForDownload(aUri)) {
where = "tab";
}
}
if (where == "tab")
gBrowser.loadOneTab(aUri, null, null, aPostData, false, false);
else
loadURI(aUri, null, aPostData, false);
}
var _BrowserToolboxCustomizeDone;
var _bottomPosition = false;
function TMP_BrowserToolboxCustomizeDone() {
var urlbar = document.getElementById("urlbar");
// onblur attribut e reset each time we exit ToolboxCustomize
if (urlbar) {
var blur = urlbar.getAttribute("onblur") || "";
if (blur.indexOf("TMP_urlBarOnBlur") == -1)
urlbar.setAttribute("onblur", blur + "TMP_urlBarOnBlur();")
}
if (gIsFirefox35 && urlbar) {
var _handleCommand = urlbar.handleCommand.toString();
if (_handleCommand.indexOf("TMP_BrowserLoadURL") == -1) {
if ("objURLsuffix" in window)
urlbar._canonizeURL = objURLsuffix.canonizeUrl;
// set altDisabled if Suffix extension installed
eval("urlbar.handleCommand ="+ _handleCommand.replace(
'var [url, postData] = this._canonizeURL(aTriggeringEvent);',
'var _data = this._canonizeURL(aTriggeringEvent); \
var altDisabled = _data.length == 3; \
var [url, postData] = [_data[0], _data[1]];'
).replace(
'if (aTriggeringEvent instanceof MouseEvent) {',
'TMP_BrowserLoadURL(aTriggeringEvent, postData, altDisabled); \
return; \
$&'
));
}
}
if (_bottomPosition) {
_bottomPosition = null;
gTMPprefObserver.tabBarPositionChanged(1);
}
var tabsToolbaritem = document.getElementById("tabs-toolbaritem");
if (tabsToolbaritem) {
tabBarScrollStatus();
checkBeforeAndAfter();
}
var searchbar = document.getElementById("searchbar");
if (searchbar) {
var _handleSearchCommand = searchbar.handleSearchCommand.toString();
// we check browser.search.openintab also for search button click
if (_handleSearchCommand.indexOf("forceNewTab") == -1) {
eval("searchbar.handleSearchCommand ="+ _handleSearchCommand.replace(
'where = whereToOpenLink(aEvent, false, true);',
'$& \
var forceNewTab = where == "current" && textBox._prefBranch.getBoolPref("browser.search.openintab"); \
if (forceNewTab) where = "tab";'
));
}
var _doSearch = searchbar.doSearch.toString();
if (_doSearch.indexOf("tabmixArg") == -1) {
eval("searchbar.doSearch ="+ _doSearch.replace(
'openUILinkIn(submission.uri.spec, aWhere, null, submission.postData);',
<![CDATA[
var tabmixArg = {backgroundPref: "extensions.tabmix.loadSearchInBackground"};
var isBlankTab = gBrowser.isBlankNotBusyTab(gBrowser.mCurrentTab);
var isLockTab = !isBlankTab && gBrowser.mCurrentTab.hasAttribute("locked");
if (aWhere == "current" && isLockTab)
aWhere = "tab";
else if ((/^tab/).test(aWhere) && isBlankTab)
aWhere = "current"
openUILinkIn(submission.uri.spec, aWhere, null, submission.postData, null, tabmixArg);
]]>
));
}
}
var undocloseButton = document.getElementById("btn_undoclose");
if (undocloseButton) {
if (gIsFirefox35 && !undocloseButton.hasAttribute("ondrop")) {
undocloseButton.setAttribute("ondrop", "nsDragAndDrop.drop(event, undocloseTabButtonObserver);");
undocloseButton.setAttribute("ondragleave", "nsDragAndDrop.dragExit(event, undocloseTabButtonObserver);");
}
else if (!gIsFirefox35 && !undocloseButton.hasAttribute("ondragdrop")) {
undocloseButton.setAttribute("ondragdrop", "nsDragAndDrop.drop(event, undocloseTabButtonObserver);");
undocloseButton.setAttribute("ondragexit", "nsDragAndDrop.dragExit(event, undocloseTabButtonObserver);");
}
}
if (gIsFirefox35)
SessionManager.toggleRecentlyClosedWindowsButton();
// Show Reload Every menu on Reload button
gTMPprefObserver.showReloadEveryOnReloadButton();
}
function TMP_BrowserCustomizeToolbar() {
if (gTabbarPosition == 1) {
_bottomPosition = true;
gTMPprefObserver.tabBarPositionChanged(0);
}
}
function TMP_onViewToolbarsPopupShowing(aPopup, aFirstMenuItem) {
// if the toolbar is not on the botton we have notiong to do here...
if (gTabbarPosition != 1)
return;
var toolbar = document.getElementById("tabs-toolbar");
if (toolbar) {
var toolbarName = toolbar.getAttribute("toolbarname");
var type = toolbar.getAttribute("type");
if (toolbarName && type != "menubar") {
var menuItem = document.createElement("menuitem");
var toolbox = document.getElementById("navigator-toolbox");
menuItem.setAttribute("toolbarindex", toolbox.childNodes.length);
menuItem.setAttribute("type", "checkbox");
menuItem.setAttribute("label", toolbarName);
menuItem.setAttribute("accesskey", toolbar.getAttribute("accesskey"));
menuItem.setAttribute("checked", toolbar.getAttribute("collapsed") != "true");
aPopup.insertBefore(menuItem, aFirstMenuItem);
menuItem.addEventListener("command", function() {
var toolbar = document.getElementById("tabs-toolbar");
toolbar.collapsed = !toolbar.collapsed;
document.persist("tabs-toolbar", "collapsed");
}, false);
}
}
}
function setURLBarFocus() {
if (gURLBar)
gURLBar.focus();
}
function dupScrollPosition(event) {
var browser = this;
var data = browser._scrollData;
browser.removeEventListener('load', dupScrollPosition, true);
var tab = gBrowser.getTabForBrowser(browser);
if (tab && tab.parentNode)
SessionManager.setScrollPosition(tab, browser, data, 15);
delete browser._scrollData;
}
function menuItemTitle(entry) {
if (entry.URI)
return getTitleFromBookmark(entry.URI.spec, entry.title);
return entry.title;
}
function saveClosedTab(tab, browser) {
if (TMP_ClosedTabs.ssIsON)
return;
var maxTabsUndo = gTabmixPrefs.getIntPref("browser.sessionstore.max_tabs_undo");
if (tabxPrefs.getBoolPref("undoClose") && maxTabsUndo > 0 && !gBrowser.isBlankBrowser(browser)) {
var bContent = browser.contentWindow;
var zoomFactor = browser.docShell.contentViewer ? browser.markupDocumentViewer.textZoom : 1;
gBrowser.closedTabs.unshift({
pos: tab._tPos,
history: browser.sessionHistory,
title: tab.getAttribute("label"),
image: tab.getAttribute("image"),
properties: SessionData.getTabProperties(tab),
scroll: bContent.scrollX + "," + bContent.scrollY + "," + zoomFactor
})
}
if (gBrowser.closedTabs.length > maxTabsUndo)
gBrowser.closedTabs.splice(maxTabsUndo, gBrowser.closedTabs.length - maxTabsUndo);
}
var autoReloadTabID = 0;
var gAutoReloadDialogAccepted;
function autoReloadDialogResult(accepted){
gAutoReloadDialogAccepted = accepted;
}
function setupAutoReload(aTab) {
aTab.autoReloadEnabled = false;
aTab.autoReloadTime = tabxPrefs.getIntPref("reload_time");
aTab.autoReloadTimerID = null;
aTab.postDataAcceptedByUser = false;
autoReloadTabID++;
}
function reloadPage(aTab) {
if (aTab == null || !aTab.parentNode)
return;
if (aTab.autoReloadEnabled == false ){
aTab.postDataAcceptedByUser = false;
return;
}
var browser = gBrowser.getBrowserForTab(aTab);
var webNav = browser.webNavigation;
var postData, referrer;
try {
var sh = webNav.sessionHistory;
if (sh) {
var entry = sh.getEntryAtIndex(sh.index, false);
postData = entry.QueryInterface(Components.interfaces.nsISHEntry).postData;
referrer = entry.QueryInterface(Components.interfaces.nsISHEntry).referrerURI;
if (postData == null)
webNav = sh.QueryInterface(nsIWebNavigation);
else if (!aTab.postDataAcceptedByUser) {
var params = Components.classes['@mozilla.org/embedcomp/dialogparam;1'].createInstance(Components.interfaces.nsIDialogParamBlock);
var stringBundle = document.getElementById("tmp-string-bundle");
params.SetString(12, stringBundle.getString('confirm_autoreloadPostData_title'));
params.SetString(0, stringBundle.getString('confirm_autoreloadPostData'));
params.SetString(2, 'alert-icon');
params.SetInt(2, 2);
window.openDialog('chrome://global/content/commonDialog.xul', '_blank', 'chrome,modal,centerscreen', params);
if (params.GetInt(0) == 0)
aTab.postDataAcceptedByUser = true;
else {
aTab.autoReloadEnabled = false;
return;
}
}
}
} catch (e) { }
browser.curScrollX = browser.contentWindow.scrollX;
browser.curScrollY = browser.contentWindow.scrollY;
var loadFlags = nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY | nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
if (postData)
webNav.loadURI(webNav.currentURI.spec, loadFlags, referrer, postData, null);
else
webNav.reload(loadFlags);
}
/* DEPRECATED */
var gIsFirefox3 = true;
function TMP_BrowserCloseWindow() { tmLog(TMP_D_MSG, true); }
function _confirmOpenTabs(numTabsToOpen) {
tmLog(TMP_D_MSG, true);
return PlacesController.prototype._confirmOpenTabs(numTabsToOpen);
}
function setTextZoom() { tmLog(TMP_D_MSG, true); }
function adjustSafebrowsingDimArea() { tmLog(TMP_D_MSG, true); }
function openMultipleLinks() { tmLog(TMP_D_MSG, true); }
var gPref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch2);
function TMP_SearchLoadURL() { tmLog(TMP_D_MSG, true); }